package com.hospital.data.simulation.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.common.pojo.TDiagnosis;
import com.hospital.data.simulation.exception.DiagnosisServiceException;
import com.hospital.data.simulation.exception.enums.DiagnosisServiceExpCode;
import com.hospital.data.simulation.mapper.TDiagnosisMapper;
import com.hospital.data.simulation.service.TDiagnosisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TDiagnosisServiceImpl extends ServiceImpl<TDiagnosisMapper, TDiagnosis> implements TDiagnosisService{
    @Autowired
    private TDiagnosisMapper diagnosisMapper;
    @Override
    public Long addDiagnosis(TDiagnosis diagnosis) {
        if (diagnosisMapper.insert(diagnosis) == 0){
            throw new DiagnosisServiceException(DiagnosisServiceExpCode.ADD_DIAGNOSIS_FAILED);
        }
        return diagnosis.getId();
    }

    @Override
    public void updateDiagnosis(TDiagnosis diagnosis) {
        if(diagnosisMapper.updateById(diagnosis) == 0){
            throw new DiagnosisServiceException(DiagnosisServiceExpCode.UPDATE_DIAGNOSIS_FAILED);
        }
    }
}
